package cn.edu.wynu.controller;

import cn.edu.wynu.pojo.Student;
import cn.edu.wynu.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class StudentController {
    @Autowired
    StudentService service;

    @RequestMapping("/queryStudentById")
    public Student queryStudentById(@RequestParam("id") Integer id) {
        return service.queryStudentById(id);
    }

    @RequestMapping(value = "/updateStudent", method = RequestMethod.POST)
    public String updateStudent(@RequestBody Student student) {
        Integer i = service.updateStudent(student);
        return i > 0 ? "修改成功" : "修改失败";
    }

    @RequestMapping(value = "/deleteStudent", method = RequestMethod.POST)
    public String deleteStudent(@RequestBody Integer id) {
        Integer i = service.deleteStudentById(id);
        return i > 0 ? "修改成功" : "修改失败";
    }
}
